home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5980 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fwrite help?
  5. Date: Thu, 22 Feb 96 00:41:44 GMT
  6. Organization: none
  7. Message-ID: <824949704snz@genesis.demon.co.uk>
  8. References: <4fmaig$7of@news.global1.net> <harmon.824165113@pegasus.montclair.edu> <danpop.824668361@rscernix> <4gf8f9$hmh@airdmhor.gen.nz>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4gf8f9$hmh@airdmhor.gen.nz>
  15.            gumboot@airdmhor.gen.nz "Simon Hosie" writes:
  16.  
  17. >In <harmon.824165113@pegasus.montclair.edu> harmon@pegasus.montclair.edu (Derek
  18. > Harmon) writes:
  19. >> first element in line, sizeof(char) for size insures compatibility on
  20. > machines
  21. >> where a character is more than one byte,
  22. >
  23. >Dan Pop:
  24. >> Nonsense.  sizeof(char) is 1 _by definition_.  The real reason behind
  25. >> writing sizeof(char) is to improve the readability of the code for the
  26. >> human reader.  To the compiler, sizeof(char) and 1 are equivalent in most
  27. >> contexts (they have the same value, but different types).
  28. >
  29. >  Oh I wish..
  30.  
  31. Your wish has been granted! :-)
  32.  
  33. >and the fact that I can argue against what you say just goes
  34. >to show (if you knew what I'd just done) how stupid I was.  Watcom supports
  35. >multi-byte chars (this is what it calls them),
  36.  
  37. The C language supports multibyte characters, but they don't (or needn't)
  38. have type char. wchar_t is defined in stddef.h for multibyte characters
  39. and 'is an integral type'.
  40.  
  41. 6.3.3.4  The sizeof operator
  42.  
  43. "The sizeof operator yields the size (in bytes) of its operand"
  44.  
  45. "When applied to an operand that has type char, unsigned char, or signed char,
  46.  (or a qualified version thereof) the result is 1."
  47.  
  48. 3.4 byte
  49.  
  50. "The unit of storage large enough to hold any member of the basic character
  51.  set of the execution environment"
  52.  
  53. 6.1.2.5 Types
  54.  
  55. "An object declared as type char is large enough to store any member of the
  56.  basic execution character set"
  57.  
  58. >if a character is more than
  59. >one byte, then it would be very difficult to fit it in to one byte, would it
  60. >not?
  61.  
  62. A byte (i.e. the units of the result of sizeof) in C is essentially defined
  63. to be that unit of memory occupied by 1 char.
  64.  
  65. -- 
  66. -----------------------------------------
  67. Lawrence Kirby | fred@genesis.demon.co.uk
  68. Wilts, England | 70734.126@compuserve.com
  69. -----------------------------------------
  70.